MyData <- expand.grid(yearsmarried = seq(min(af$yearsmarried),
max(af$yearsmarried)), children = c("yes", "no"),
religiousness = seq(min(af$religiousness), max(af$religiousness)))
MyData$Predicted <- predict(Mod_nb_final, newdata = MyData,
type = "response")
ggplot(MyData, aes(x = yearsmarried, y = Predicted,
color = religiousness)) + geom_line(aes(group = religiousness),
size = 1.5) + facet_grid(~children, labeller = label_both) +
scale_color_gradient(low = "yellow", high = "red") +
geom_point(data = af, aes(x = yearsmarried, y = affairs),
position = position_jitter(width = 1, height = 1))